<?php
/**
 * 点大商城（www.diandashop.com） - 微信公众号小程序商城系统!
 * Copyright © 2020 山东点大网络科技有限公司 保留所有权利
 * =========================================================
 * 版本：V2
 * 授权主体：海南芒点网络科技有限公司
 * 授权域名：kf.hnmangdian.com
 * 授权码：iuGYepyTlKxWomKwhgsupaLmF
 * ----------------------------------------------
 * 您只能在商业授权范围内使用，不可二次转售、分发、分享、传播
 * 任何企业和个人不得对代码以任何目的任何形式的再发布
 * =========================================================
 */

namespace app\common;
use think\facade\Db;
use think\facade\Log;
class PayRetrun
{
   
    public function index(){
        $request = $_REQUEST;
        $type =  $request['type'];
        if($type =='quickpay'){
            $this-> quickpay($request);
        }
    }
    public function quickpay($request=[]){
        //汇付快捷支付页面支付完成点击返回后，请求的链接是post,造成405不允许，加此页面进行中转跳转
        $aid = $request['aid'];
        if(getcustom('pay_huifu_quickpay',$aid)){
            if($request['url']){
                if(in_array($request['p'],['h5','mp'])){

                    echo '<script type="text/javascript">window.location.href="'.m_url(urldecode($request['url']),$aid).'";</script>';
                    exit; // 确保脚本停止执行
                }elseif ($request['p'] =='app'){
                    echo '<!DOCTYPE html><html>'."\r\n";
                    echo '<head>'."\r\n";
                    echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'."\r\n";
                    echo '<meta name="viewport" content="width=device-width,minimum-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />'."\r\n";
                    echo '<meta name="robots" content="index, follow" />'."\r\n";
                    echo '<title>信息提示</title>'."\r\n";
                    echo '<script type="text/javascript" src="/static/js/uni.webview.1.5.4.js"></script>'."\r\n";
                    echo '</head>'."\r\n";
                    echo '<body>'."\r\n";
                    echo '<h2 style="text-align:center;padding-top:100px">跳转中...</h2>'."\r\n";
                    echo '<script>'."\r\n";
                    echo 'document.addEventListener(\'UniAppJSBridgeReady\', function() {'."\r\n";
                    echo '	uni.redirectTo({'."\r\n";
                    echo '	  url:"'.$request['url'].'"'."\r\n";
                    echo '	});'."\r\n";
                    echo '});'."\r\n";
                    echo '</script>'."\r\n";
                    echo '</body></html>';
                    die;
                }else{

                }
            }
        }
    }

}